package main.java.com.lemon.dao;

import main.java.com.lemon.utils.JdbcUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author Aupt
 * @create 2021-10-17-20:56
 */
public class StudentDao {
    public static int delete(String username){
        Connection conn = null;
        PreparedStatement pstm = null;

        try {
            conn = JdbcUtils.getConnection();
            String sql = "delete from student where username = ?";
            pstm = conn.prepareStatement(sql);
            pstm.setString(1,username);
            int i = pstm.executeUpdate();
            return i;
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.close(pstm,conn);
        }
        return 0;
    }
}
